<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card shadow="hover">
      <!-- 权限列表区域 -->
      <el-table :data="rightsList"  border stripe style="width: 100%">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="authName" label="权限名称" ></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <!-- 因为要自定义列所以使用作用域插槽 -->
          <template v-slot="{row}">
            <el-tag v-if="row.level==='0'" effect="dark" type="">一级</el-tag>
            <el-tag v-else-if="row.level==='1'"effect="dark" type="success">二级</el-tag>
            <el-tag v-else effect="dark" type="warning">三级</el-tag>
          </template>

        </el-table-column>
        
    </el-table>
    </el-card>
  </div>
</template>
<script>
import {getRightsList} from '../../networks/power'
export default {
  name:'Rights',
  data() {
    return {
      rightsList:[]
    }
  },
  created() {
    //请求权限列表数据
   this.getRightsListInfo();
  },
  methods: {
    //请求权限列表数据的方法
    getRightsListInfo(){
      getRightsList().then(res=>{
        console.log(res);
        if(res.meta.status!==200) return this.$message.error(res.meta.msg);
        //获取成功，保存数据
        this.rightsList=res.data;
        console.log(this.rightsList,"RightsList");
    })
    }
  },
}
</script>
<style scoped>
</style>